import com.mysql.cj.jdbc.MysqlDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: wx
 * Date: 2023-11-13
 * Time: 20:56
 */
public class Testjdbc {
    public static void main(String[] args) throws SQLException {
        DataSource dataSource = new MysqlDataSource();
        ((MysqlDataSource)dataSource).setUrl("jdbc:mysql://127.0.0.1:3306/newsql?characterEncoding=utf8&useSSL=false");
        ((MysqlDataSource)dataSource).setUser("root");
        ((MysqlDataSource)dataSource).setPassword("1234");

        Connection connection = dataSource.getConnection();
        String sql = "insert into goods values(5,'宝格丽香水',1299,60)";
        PreparedStatement statement = connection.prepareStatement(sql);

        int n = statement.executeUpdate();
        System.out.println("n = "+ n);

        statement.close();
        connection.close();
    }



}
